/**
 * 分类页面状态
 */
export default class TStatus{
  isAdd = true; //是否新增一级分类
  selectImageType = 0;//type 0:橱窗图 单   1:色卡样式图 单    2:试戴图单    3:明细图上传 多
  //查看图片
  modalImage = {
    isShow: false,
    url: ''
  };
  //查看图片
  modalImageSelect = {
    isShow: false,
    isLoading: false
  };
  modalAction = {
    isShow: false,
    isLoading: false,
    title: '',
    content: ''
  };
  modalSort = {
    isShow: false,
    isLoading: false,
    title: '',
  };
  modalMove = {
    isShow: false,
    isLoading: false,
    title: '',
  };

  deleteId = '';
  deleteLevel  = 0;
  deleteName = '';

  selectedLevel1 = {
    id:"",
    name:"",
    index:-1,
    isPlaceholder:false,
    state:0//0未选中，1选中
  };
  selectedLevel2 = {
    id:'',
    name:"",
    index:-1,
    isPlaceholder:false,
    state:0
  };
  selectedLevel3 = {
    id:'',
    index:-1,
    isPlaceholder:false,
    state:0
  };
  modalShowroom = {
    isShow: false,
    isLoading: false,
    title: '',
  };
  resetDeleteInfo(){
    this.deleteId = '';
    this.deleteLevel  = 0;
    this.deleteName = '';
    return this;
  }

  resetSelectedLevel(...levels){
    let that = this;
    levels.forEach(function (level) {
      switch (level) {
        case 1:
          that.selectedLevel1.state=0;
          that.selectedLevel1.id="";
          that.selectedLevel1.index=-1;
          that.selectedLevel1.isPlaceholder = false;
          break;
        case 2:
          that.selectedLevel2.state=0;
          that.selectedLevel2.id="";
          that.selectedLevel2.index=-1;
          that.selectedLevel2.isPlaceholder = false;
          break;
        case 3:
          that.selectedLevel3.state=0;
          that.selectedLevel3.id="";
          that.selectedLevel3.index=-1;
          that.selectedLevel3.isPlaceholder = false;
          break;
        default:
          break;
      }
    });
  }

  setSelectedLevel1(classification, index){
    this.selectedLevel1.index = index;
    this.selectedLevel1.id = classification.id;
    this.selectedLevel1.state = 1;
    this.selectedLevel1.name = classification.name;
    this.selectedLevel1.isPlaceholder = classification.isPlaceholder;
    this.selectedLevel1.type = classification.type;
  }

  setSelectedLevel2(classification, index){
    this.selectedLevel2.index = index;
    this.selectedLevel2.id = classification.id;
    this.selectedLevel2.state = 1;
    this.selectedLevel2.name = classification.name;
    this.selectedLevel2.isPlaceholder = classification.isPlaceholder;
    this.selectedLevel2.type = classification.type;
  }

  setSelectedLevel3(classification, index){
    this.selectedLevel3.index = index;
    this.selectedLevel3.id = classification.id;
    this.selectedLevel3.state = 1;
    this.selectedLevel3.isPlaceholder = classification.isPlaceholder;
    this.selectedLevel3.type = classification.type;
  }

  setDeleteItem(id, level, name){
    this.deleteId = id;
    this.deleteLevel = level;
    this.deleteName = name;
  }

  showSortModal(title){
    this.modalSort.isShow = true;
    this.modalSort.title = title;
  }

  hideSortModal(){
    this.modalSort.isShow = false;
    this.modalSort.isLoading = false;
  }

  showDeleteSureModal(title,content){
    this.modalAction.title = title;
    this.modalAction.content = content;
    this.modalAction.isShow = true;
  }

  showDeleteModal(){
    this.modalMove.isLoading = true
  }
  hideDeleteModal(){
    this.modalMove.isShow = false;
    this.modalMove.isLoading = false;
  }


}
